package com.fancymusic.service.impl;

import com.fancymusic.dao.IUserDao;
import com.fancymusic.entity.User;
import com.fancymusic.service.IUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private IUserDao userDao;

    @Override
    public List<User> findUserList() {
        return userDao.findUserList();
    }

    @Override
    public Boolean insertUser(User user) {
        return userDao.insertUser(user);
    }

    @Override
    public PageInfo<User> findUserListByPage(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        List<User> userList = findUserList();
        PageInfo<User> userPageInfo = new PageInfo<>(userList);
        return userPageInfo;
    }

    @Override
    public User findByUserId(Integer userId) {
        return userDao.findByUserId(userId);
    }

    @Override
    public Boolean updateUser(User user) {
        return userDao.updateUser(user);
    }
}
